package com.lechuang.goods.service.impl;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lechuang.goods.dto.GoodsCategoryListDTO;
import com.lechuang.goods.entity.GoodsCategory;
import com.lechuang.goods.service.GoodsCategoryService;
import com.lechuang.goods.mapper.GoodsCategoryMapper;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author apple
* @description 针对表【goods_category(商品分类表)】的数据库操作Service实现
* @createDate 2024-06-21 14:10:45
*/
@Service
public class GoodsCategoryServiceImpl extends ServiceImpl<GoodsCategoryMapper, GoodsCategory>
    implements GoodsCategoryService{

    @Override
    public List<GoodsCategory> list(GoodsCategoryListDTO goodsCategoryListDTO) {
        return this.lambdaQuery()
                .like(StrUtil.isNotEmpty(goodsCategoryListDTO.getSelectText()), GoodsCategory::getName, goodsCategoryListDTO.getSelectText())
                .orderByAsc(GoodsCategory::getSort)
                .list();
    }

    @Override
    public List<GoodsCategory> getByParentId(Long id) {
        return this.lambdaQuery()
                .eq(GoodsCategory::getParentId, id)
                .list();
    }

    @Override
    public List<GoodsCategory> getByIds(List<Long> categoryIdList) {
        return this.lambdaQuery()
                .in(GoodsCategory::getId, categoryIdList)
                .list();
    }
}




